<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*     function f1() {
             var n = 33;
             return function f2() {
               alert(n);
             };
           }
           f1()(); */

      /*     function f1() {
             var n = 22;
             (function f2(i) {
               alert(i);
             })(n);
           }
           f1();
      */

      // for(var i=1;i<=3;i++){ //同步执行
      // 	setTimeout(function(){ //异步执行
      // 	  console.log(i);
      // 	},0);
      //  }

      /* 
      for (var i = 1; i <= 3; i++) {
        (function (a) {
          // console.log(a);
          setTimeout(function () {
            console.log(a);
          }, 0);
        })(i);
      } */

      for (var i = 1; i <= 5; i++) {
        // console.log(i);
        ((a) => {
          setTimeout(() => {
            // console.log(a);
          }, a * 100);
        })(i);
      }
      console.log(i);
    </script>
  </body>
</html>
